<?php if ( !defined('BASEPATH')) exit('No direct script access allowed');

class Barcode_print extends CI_Controller {

	public function __construct(){
		parent::__construct();
		$this->load->model('wus');
		$this->load->model($this->session->userdata('formodel'));
		$this->load->library('variable');
		$this->load->library('zend');
		$this->load->helper('file');
        //load in folder Zend
        $this->zend->load('Zend/Barcode');

	}
	public function index(){
	  $this->load->view('layouts/header',$this->variable->load_data($this->session->userdata('title')));
	  $this->load->view($this->session->userdata('formain'));
	  $this->load->view('layouts/footer');
	}

	public function remove_temp(){

		$path = "assets/barcodes/temp";

		delete_files($path,"assets/barcodes/tmp");
	}
	public function gen_barcodes(){
		$path = "assets/barcodes/temp";
		if(!is_dir($path)) //create the folder if it's not already exists
    	{
      		mkdir($path,0755,TRUE);
    	}

		$barcode = $this->input->post('gen_serial');
		$imageResource = Zend_Barcode::factory('code128', 'image', array('text'=>$barcode), array('imageType' => 'png'))->draw();
        imagepng($imageResource, 'assets/barcodes/temp/'.$barcode.'.png');

        echo json_encode($barcode);
	}

}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */